﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using System.Diagnostics;

public partial class SSFGL_SSFGLList : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    Stopwatch sw = new Stopwatch();
    sw.Start();
    //代码部分
    if (!Page.IsPostBack)
    {
      if (CommonUse.GetID("mode") == "")
      {
        if (!ProjectPrivate.GetQX("18"))
        {
          Server.Transfer("~\\blank.aspx");
        }
        ASPxGridView1.Columns[ASPxGridView1.Columns.Count - 1].Visible = false;
      }
      else
      {
        if (!ProjectPrivate.GetQX("10"))
        {
          Server.Transfer("~\\blank.aspx");
        }
      }
      if (CWSD.GetSDZT("否"))
      {
        Server.Transfer("~\\sd.aspx");
      }
      date1.Date = CommonUse.GetYC();
      date2.Date = CommonUse.GetYM();
    }
    BindGrid();

    sw.Stop();
    //Response.Write("本次执行共耗时:" + sw.ElapsedMilliseconds + "毫秒！");
  }

  protected void BindGrid()
  {
    DataSet ds = JFSJ.GetDS_JFJL(date1.Text, date2.Text, CommonUse.GetID("mode") == "" ? "" : SysManage.Get_User);
    ASPxGridView1.DataSource = ds;
    ASPxGridView1.DataBind();
  }

  protected void lbDelete_Command(object sender, CommandEventArgs e)
  {
    List<CommandInfo> cis = new List<CommandInfo>();

    cis.Add(CommonUse.DeleteCI("SJLR_jfSJ", "jfsjid", e.CommandArgument.ToString()));
    cis.Add(CommonUse.DeleteCI("SJLR_jfmx", "JF_FKSJID", e.CommandArgument.ToString()));

    if (DbHelperSQL.ExecuteSqlTran(cis) > 0)
    {
      BindGrid();
    }
  }

  protected void lbSB_Command(object sender, CommandEventArgs e)
  {
    SqlParameter[] cmdParams = null;
    string sSql = "";
    List<CommandInfo> cis = new List<CommandInfo>();
    CommandInfo ci;

    sSql = "update SJLR_jfsj set bqsj_SFSd=1 where jfsjid=" + e.CommandArgument.ToString();
    ci = new CommandInfo();
    ci.CommandText = sSql;
    ci.Parameters = cmdParams;
    cis.Add(ci);

    if (DbHelperSQL.ExecuteSqlTran(cis) > 0)
    {
      BindGrid();
    }
  }

  protected void btnQuery_Click(object sender, EventArgs e)
  {

  }

  protected void btnExport_Click(object sender, EventArgs e)
  {
    this.ASPxGridViewExporter1.WriteXlsToResponse();

  }

}
